<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use  Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\User;

/**
 * 个人成绩
 */
class Score extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'score';
    protected $guarded = [];
    /**
     * 查询时是关联查询，所以不需要id
     * 但是后续更改会不方便
     * 也可以在with里面写闭包
     */
    protected $hidden = [
        'id',
        'deleted_at'
    ];

    const CREATED_AT = 'create_time';
    const UPDATED_AT = 'update_time';


    public function user()
    {
        return $this->belongsTo(User::class, 'id');
    }
}
